package com.tjhk.netty.mapping;

import com.tjhk.netty.mapping.annotation.HandlerMapper;
import com.tjhk.netty.util.ClassUtils;

import java.util.List;

/**
 *
 */
public class DefaultHandlerRegister extends AbstractHandlerRegister {

    public DefaultHandlerRegister(String packageName) {
        List<Class<?>> handlerMapperClasses = ClassUtils.getClassList(packageName, HandlerMapper.class);
        for (Class<?> handlerMapper : handlerMapperClasses) {
            try {
                Object bean = handlerMapper.newInstance();
                super.registerHandlers(bean);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}
